#include <stdio.h>

int main()
{
	char hieroglyphs[1000][3];
	//char buf[ 3 ];

	int N = 0;
	scanf( "%d", &N );
	for( int i = 0; i < N; ++i )
		scanf( "%s", hieroglyphs[i] );

	char buf[3];
	scanf( "%s", buf );
	char ch = buf[0];

	for( int i = 0; i < N; ++i )
		if( hieroglyphs[i][0] == ch )
			printf( "%s\n", hieroglyphs[i] );

	return 0;
}

